package com.antoco.operation.bigscreen.repository;

import com.antoco.operation.bigscreen.model.entity.SensorWarn;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import java.util.List;


@Repository
public interface SensorWarnRepository extends PagingAndSortingRepository<SensorWarn, String> {

  @Query(value = "SELECT * FROM sensor_warn WHERE sensor_id IN (SELECT id FROM sensor WHERE dev_big_type = ?1) ORDER BY id DESC",
            nativeQuery = true)
  List<SensorWarn> findBySensorType(String type);

  @Query(value = "SELECT * FROM sensor_warn WHERE sensor_id = ?1 ORDER BY id DESC",
          nativeQuery = true)
  List<SensorWarn> findBySensorId(String sensorId);

}